package qq.activity.fragment;

import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;


public class CchMyFragment extends Fragment {


    @BindView(R.id.tv_my_name)
    TextView TvMyName;
    @BindView(R.id.tv_my_position)
    TextView TvMyPosition;
    CchMainActivity fragmentMainActivity;
    private Context context;
    @Override
    public void onAttach(Context context) {
        super.onAttach(context);
        this.context = context;
        fragmentMainActivity = (CchMainActivity) context;
    }

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_my, container, false);
        ButterKnife.bind(this, view);
        initView();
        return view;
    }
    private void initView() {
        SharedPreferences sharedPreferences =getActivity().getSharedPreferences("cch",Context.MODE_PRIVATE);
        TvMyName.setText(  sharedPreferences.getString("nickname",""));
        if ( sharedPreferences.getString("classesId","").equals("130")){
            TvMyPosition.setText("专硕二班");
        }
    }

    @OnClick(R.id.ll_my_editpassword)
    public void ll_my_editpassword(){
        Intent intent = new Intent(context, ResetPwdActivity.class);
        startActivity(intent);
    }
    @OnClick(R.id.ll_my_info)
    public void ll_my_info(){
        Intent intent = new Intent(context, EditInfoActivity.class);
        startActivity(intent);
    }
    @OnClick(R.id.ll_my_exit)
    public void exit(){
      System.exit(0);
    }
}
